package com.nineclock.system.controller;

import com.nineclock.api.system.controller.SmsControllerApi;
import com.nineclock.common.entity.Result;
import com.nineclock.system.service.SmsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/sms")
public class SmsController implements SmsControllerApi {
    @Autowired
    SmsService smsService;

    @GetMapping("/code")
    @Override
    public Result sendSms(@RequestParam("mobile") String mobile, @RequestParam("type") String type) {
        smsService.sendSms(mobile, type);
        return Result.success();
    }

    // 校验验证码
    @GetMapping("/verify")
    @Override
    public Result<Boolean> verify(@RequestParam("checkcode") String checkCode, String type, String mobile) {
        Boolean result = smsService.verify(checkCode, type, mobile);
        return Result.success(result);
    }
}
